<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%--
- Author(s): Robert
- Date: 2018-03-29 16:55:01
- Description:
    --%>
<head>
<title>我创建的任务</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="<%=request.getContextPath()%>/common/nui/nui.js"
	type="text/javascript">
        </script>
</head>
<body style="width: 98%; height: 95%;">
<style>
	.tab{width:100%;display:flex;border:1px solid #eee;border-radius:5px;margin-bottom:10px;}
	.tab-i{background:rgba(252, 217, 179, 1);cursor:pointer;flex:1;padding:0px 5px;height:40px;line-height:40px;position:relative;text-align:center;font-weight:bold;border-right:1px solid #eee;margin-bottom:10px;}
	.tab-i:after{content:"";position:absolute;bottom:-10px;left:0;width:100%;height:10px;background:rgba(129, 197, 52, 1);}
	.tab-i.activeTb~.tab-i{
		background:#fff;
	}
	.tab-i.active:after{
		background:rgba(129, 197, 52, 1);
		
	}
	.tab-i.active~.tab-i:after{
		background:#eee;
		
	}
	.tab-i.active~.tab-i{
		font-weight:500;
	}
	.tab-i.active{
		font-weight:bold;
	}
	.savebtn{
		width:100px;
		height:100%;
		height:40px;
		line-height:50px;
		text-align:center;
		background:rgb(230,86,52);
		font-weight:bold;
		color:#fff;
		font-size:14px;
		text-decoration:none;
		box-shadow:-3px 3px 10px #eee;
		padding-bottom:10px;
		border-top-right-radius:5px;
		border-bottom-right-radius:5px;
		transition:all 0.5s
	}
	.savebtn:hover{
		box-shadow:-0px 0px 5px #eee inset;
	}
	
	.mini-panel-header{
		font-size:12px;
		font-weight:bold;
	}
	.header-text{
		font-size:12px;
		font-weight:bold;
	}
	</style>
	<div class="tab">
		<div class="tab-i active" onClick="tabClick(1)">项目发起</div>
		<div class="tab-i" onClick="tabClick(2)">技术需求调研</div>
		<div class="tab-i" onClick="tabClick(3)">需求整理</div>
		<div class="tab-i " onClick="tabClick(4)">需求分析</div>
		<div class="tab-i" onClick="tabClick(5)">设计阶段</div>
		<div class="tab-i" onClick="tabClick(6)">开发阶段</div>
		<div class="tab-i" onClick="tabClick(7)">测试阶段</div>
		<div class="tab-i" onClick="tabClick(8)">运维阶段</div>
		<a class="savebtn" href="<%= request.getContextPath()%>/xmgl/ZhmyDemandChangeList.jsp?projectId=<%=request.getParameter("projectId")%>" >需求变更</a>
		
	</div>
	
<!--	<div class="nui-panel" title="当前进度人员管理" iconCls="icon-add" style="width: 100%; height: 10%;" showToolbar="false" showFooter="true">
		<div id="form0" class="nui-form" align="left" style="height: 100%">
			
		</div>
	</div>-->
	<div class="header-text">当前进度人员管理</div>
	<div>
		<table id="table1" class="table" style="height: 100%">
				<tr>
					<td class="form_label">负责人:</td>
					<td colspan="1">
						<input id="lookup6"name="fuzerenid" class="nui-lookup"textField="partyId" valueField="partyId" popupWidth="auto"
						popup="#gridPanel6" grid="#datagrid6" multiSelect="false" />
					</td>
					<td class="form_label">参与人:</td>
					<td colspan="1">
						<input id="lookup4"name="canyuren" class="nui-lookup"textField="partyId" valueField="partyId" popupWidth="auto"
						popup="#gridPanel4" grid="#datagrid4" multiSelect="true" style="width:500px;"/>
					</td>
					<td class="form_label">其他人:</td>
					<td colspan="1">
						<input id="other" name="qitaren" value="参与人"/>
					</td>

					<td rowspan="1">
						<a class="nui-button" onclick="savePeopleOfCurrentStat()">保存 </a>
					</td>
				</tr>
			</table>
	</div>
<!--	<div class="nui-panel" title="版本筛选" iconCls="icon-add"
		style="width: 100%; height: 10%;" showToolbar="false"
		showFooter="true">
		
	</div>-->
	<div class="header-text">版本筛选</div>
	<div id="form1" class="nui-form" align="left" >
		
		<!-- 用户查询表格的参数, 更改状态,只需更改这个参数,然后,reload -->
		<input class="nui-hidden" name="projectid">
		<input class="nui-hidden" name="status">
	
			<!-- 排序字段 -->
			<table id="table1" class="table" style="height: 100%">
				<tr>
					<td class="form_label">版本选择:</td>
					<td colspan="1"><input id="lookup5"
						name="criteria/_expr[1]/zhmyVersionChange.vcId" class="nui-lookup"
						textField="vcVersionNumber" valueField="vcId" popupWidth="auto"
						popup="#gridPanel5" grid="#datagrid5" multiSelect="false" />
						 <input class="nui-hidden" name="criteria/_expr[1]/_op" value="=">
					</td>
				<!--	todo: 加上这个导致,查询不分版本-->

					<td rowspan="1">
						<a class="nui-button" onclick="search()">查询 </a>
						<a class="nui-button" onclick="reset()"> 重置 </a>
					</td>
				</tr>
			</table>
		</div>
	<div style="width: 100%; height: calc(80% - 90px);">
		<div class="nui-fit">
			<div id="datagrid1" dataField="zhmyScheduleFile" class="nui-datagrid"
				style="width: 100%; height: 100%;"
				url="com.zhmy.xmgl.zhmyprojectmanage.getProgramManageDoc.biz.ext"
				pageSize="10" showPageInfo="true" multiSelect="true"
				 allowSortColumn="false"
				ondrawcell="addLink">
				<div property="columns">
					<!--<div type="indexcolumn"></div>
					<div type="checkcolumn"></div>-->
					<div field="sfId" headerAlign="center" allowSort="true"visible="false">sfId</div>
					<div name="filename" field="zhmyFileTemplate.ftName" headerAlign="center" allowSort="true">文档类型</div>
					<div field="zhmyVersionChange.vcVersionNumber" headerAlign="center" allowSort="true">版本</div>
					<div field="sfName" headerAlign="center" allowSort="true">用户文档名称</div>
					<div field="sfAddress" headerAlign="center" allowSort="true" visible="false">附件地址</div>
					<div field="sfCtime" headerAlign="center" allowSort="true">创建时间</div>
					<!--<div field="sfUtime" headerAlign="center" allowSort="true">更新时间</div>-->
					<div name="oprate" headerAlign="center">操作</div>
				</div>
			</div>
		</div>
		<style>
			.addbtn{
				width:100%;
				text-align:center;
			}
			.add.mini-button{
				background:rgb(230,86,52);
				border:0;
				color:#fff;
				font-weight:bold;
			}
			.add .mini-button:hover{
				background:#FF4200;
				border:0;
			}
			.acte{
				float:right;
			}
			.acte.mini-button{
				background:rgba(129, 197, 52, 1);
				border:0;
				color:#fff;
				font-weight:bold;
			}
			.acte .mini-button:hover{
				background:rgba(129, 197, 52, 1);
				border:0;
			}
		</style>
		<div id="buttomview" class="addbtn"></div>
	</div>
			

<!--  look up 5 -->
	<div id="gridPanel5" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>接收人:</span> <input id="keyText5" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick5" /> <a
					class="nui-button" onclick="onSearchClick5">查询</a> <a
					class="nui-button" onclick="onClearClick5">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick5">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagrid5" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.zhmyprojectmanage.getVersionListOfProject.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="vcVersionNumber" width="120" headerAlign="center"
					allowSort="true">版本名称</div>
			</div>
		</div>
	</div>
	
	<!--  look up 4 -->
	<div id="gridPanel4" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>接收人:</span> <input id="keyText4" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick4" /> <a
					class="nui-button" onclick="onSearchClick4">查询</a> <a
					class="nui-button" onclick="onClearClick4">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick4">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagrid4" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.zhmytaskbiz.queryReceiverName.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="partyId" width="120" headerAlign="center"
					allowSort="true">姓名</div>
			</div>
		</div>
	</div>
	
		<!--  look up 6 -->
	<div id="gridPanel6" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>发布人:</span> <input id="keyText6" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick6" /> <a
					class="nui-button" onclick="onSearchClick6">查询</a> <a
					class="nui-button" onclick="onClearClick6">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick6">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagrid6" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.zhmytaskbiz.queryReceiverName.biz.ext">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="partyId" width="120" headerAlign="center"
					allowSort="true">姓名</div>
			</div>
		</div>
	</div>



	<script type="text/javascript">
	

    	
	//设置form1的默认查询参数
	//从父页面传递过来的项目id
	
	var globalStatus = 1;
	
	//从url路径获取projectid
    var globalprojectId = "<%=request.getParameter("projectId")%>";
    if (globalprojectId > 0 ) {
    	$("[name$=projectid]").val(globalprojectId);
    } else {
    	$("[name$=projectid]").val(1);//for debug
		globalprojectId = 1;
    }
    
   // console.log(globalprojectId);

	//设置默认页面状态
	$("[name$=status]").val(1);
	
	nui.parse();
	var grid = nui.get("datagrid1");
	
    //call function on startup
    var green_bar_status = 1;
	getCurrentState();
	
	var tab = document.getElementsByClassName('tab-i')
	
	function setButtomView(mode) {
		var view = document.getElementById('buttomview');		
		//var buttonAdd = "<a class='nui-button add' style='padding:5px 10px;' onclick='setButtomView()'>增加自定义文档 </a>";
		//var buttonNext = "<a class='nui-button acte' style='padding:5px 10px;' onclick='setProgramGotoNextStep()'>通过 :到下一阶段</a>";
		
		var styleGreen = "style='float:right;  background:#7fb334; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:8px 20px; border:none;'";
		
		var styleRed = "style='margin-left:20px; background:#e66534; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:8px 20px; border:none;'";
		
				
		var addButton = "<a><button "+styleRed+" onclick='addSelfDoc()'>增加自定义文档</button></a>";
		var nextButton = "<a><button "+styleGreen+" onclick='setProgramGotoNextStep()'>通过 :到下一阶段</button></a>";
				
		if (mode == 2) {
			view.innerHTML=addButton;
		} else {
			view.innerHTML=addButton+nextButton;
		}
	}
	
	//控制绿色进度条位置
	function loadtab(index){
		for(var i = 0;i< tab.length;i++){
			tab[i].className = 'tab-i';
		}
		tab[index - 1].className += ' active';
	}
	
	//tab点击响应函数
	function tabClick(index){
		globalStatus = index;
	
		//3改成全局变量--默认显示的进度
		loadtab(green_bar_status);
		tab[index - 1].className += ' activeTb';
		
		showUIState(index);
		getPeopleOfCurrentState(index);
	}
	
	function showUIState(index) {
		var formData = new nui.Form("#form1").getData(false,false);
		formData.status=index;
		formData.projectid = globalprojectId;
		//console.log(formData);

   		grid.load(formData);
   		
   		//clean people search history
   		onClearClick6();
   		onClearClick4();
	}
	
	//给当前项目，当前状态增加自定义文档
	function addSelfDoc() {
	
	var projectid2 = globalprojectId;//属于哪个项目
	var projectstatus2 = globalStatus;//属于项目管理中的那个状态
	
	var json = "{'projectid':" + projectid2 + ",'projectstatus':"+ projectstatus2 +"}";
	
		$.ajax({
                    url:"com.zhmy.xmgl.zhmyprojectmanage.addSelfDefinedDoc.biz.ext",
                    type:'POST',
                    data:json,
                    cache: false,
                    contentType:'text/json',
                    success:function(text){
                        var returnJson = nui.decode(text);
                        if(returnJson.exception == null){
                        	
                            grid.reload();
                            nui.alert("增加成功", "系统提示", function(action){});
                            }else{
                                //grid.unmask();
                                nui.alert("增加失败", "系统提示");
                            }
                        }
                 });
                      
	}
	

	
	//获取当前项目所在的进度
	//注意:在此页面可根据上面的导航按钮查看项目的每个状态的数据，，而获取的当前进度，是指当前项目完成的进度，并不是显示进度
	function getCurrentState(){
	
			var projectid2 = globalprojectId;
			var json = "{'projectid':" + projectid2+"}";
	
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.getProgramCurrentState.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	                	var currentState = returnJson['currentState'];
	                	
	                	green_bar_status = currentState;
	                	tabClick(currentState);
	                	if (green_bar_status >=8) {
	                		setButtomView(2);
	                	} else {
	                		setButtomView(1);
	                	}
	                	
	                }else{
	                    nui.alert("获取项目当前状态失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
	                }
	            }
	   		 });
   		 }
	
	//获取当前项目，当前项目状态的，负责人，参与人，其它人
	function getPeopleOfCurrentState(currentStatus){
	
			var projectid2 = globalprojectId;
			var json = "{'projectid':" + projectid2+",'status':"+currentStatus+"}";
			
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.getProgramCurrentStatePeople.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	                	returnJson = returnJson['result'];
	          
	                	for(var i = 0;i < returnJson.length;i++){
		                	// have one child only
		                	var fu_ze_ren = returnJson[i]['scheduleHead'];
		                	var can_yu_ren = returnJson[i]['schedultMember'];
		                	var qi_ta_ren = returnJson[i]['scheduleOthers'];
		                	
							nui.get("lookup6").setText(fu_ze_ren);
							nui.get("lookup4").setText(can_yu_ren);
							$("[name$=qitaren]").val(qi_ta_ren);
	                	}
	                }else{
	                    nui.alert("获取项目当前状态的人员失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
	                }
	            }
	   		 });
   		 }
   		 
   		 //保存负责人id,参与人,其他人
   		 //参数:?projectid=1&status=1&fuzerenid=1&canyuren=robert&qitaren=qitaren
   		 function savePeopleOfCurrentStat(){
   		 	var fuzeren = nui.get("lookup6").getText();
			var canyuren = nui.get("lookup4").getText();
			//var qitaren = $("#other").val();//ok
			var qitaren = document.getElementById("other").value;//ok too
	
			var projectid2 = globalprojectId;
			var status2 = globalStatus;
			
			//var fuzerenid2 = fuzeren;
			//var canyuren2=canyuren;
			//var qitaren2 = qitaren;
			//var json = "{'projectid':" + projectid2+",'status':"+status2+",'fuzerenid':"+fuzerenid2+",'canyuren':\'"+canyuren2+"\','qitaren':"+qitaren2+"}";
			
			var jsonObject = new Object();
			jsonObject.projectid = globalprojectId;
			jsonObject.status = globalStatus;
			jsonObject.fuzerenid = fuzeren;
			jsonObject.canyuren = canyuren;
			jsonObject.qitaren = qitaren;
			
			var json2 = nui.encode(jsonObject);
			console.log(json2);
	
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.savePersonOfProgramStatus.biz.ext",
	            type:'POST',
	            data:json2,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	           // console.log(text);
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	                	
	                	nui.alert("保存成功");
	                }else{
	                    nui.alert("保存项目当前状态的人员失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
	                }
	            }
	   		 });
   		 }
   		 
   		 //设置项目进入到下一个阶段
   		 //ui上右下角的通过按钮，点击后调用此函数
   		 function setProgramGotoNextStep(){
   		 
   		 	if (green_bar_status >= 8) {
   		 		nui.alert("已经达到最后状态", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
   		 		return;
   		 	}
	
			var projectid2 = globalprojectId;
			var json = "{'projectid':" + projectid2+"}";
	
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.gotoNextProgramState.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
		                green_bar_status += 1; 
		                tabClick(green_bar_status);
		                
		                if (green_bar_status == 8) {
		                	setButtomView(2);
		                }
		                
	                }else{
	                    nui.alert("设置项目进入下一个阶段失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                           // CloseWindow("saveFailed");
	                        }
	                    });
	                }
	            }
	   		 });
   		 }

        //查询,根据所填版本,重新查询表格
        function search() {
   
        //    var form = new nui.Form("#form1");
         //   var json = form.getData(false,false);
         //   grid.load(json);//grid查询
         
         showUIState(globalStatus);
        }

        //重置查询条件
        function reset(){
            var form = new nui.Form("#form1");//将普通form转为nui的form
            form.reset();
        }

        //enter键触发查询
        function onKeyEnter(e) {
            search();
        }


                                
                                
  		//选择办班的操作代码
        var grid5 = nui.get("datagrid5");
		var keyText5 = nui.get("keyText5");
		//grid5.load();
		grid5.load({
				key : keyText5.value ,
				projectid: globalprojectId
			});
	 	function onSearchClick5(e) { 
			grid5.load({
				key : keyText5.value ,
				projectid: globalprojectId
			});
		}
			
		function onCloseClick5(e) {
			var lookup2 = nui.get("lookup5");
			lookup2.hidePopup(); 
		}
			
		function onClearClick5() {
			var lookup2 = nui.get("lookup5");
			lookup2.deselectAll();
		}


		//my4
        var grid4 = nui.get("datagrid4");
		var keyText4 = nui.get("keyText4");
		grid4.load();
	 	function onSearchClick4(e) { 
			grid4.load({
				key : keyText4.value 
			});
		}
		
		function onCloseClick4(e) {
			var lookup2 = nui.get("lookup4");
			lookup2.hidePopup(); 
		}
		
		function onClearClick4() {
			var lookup2 = nui.get("lookup4");
			lookup2.deselectAll();
		}
		
		//my6
        var grid6 = nui.get("datagrid6");
		var keyText6 = nui.get("keyText6");
		grid6.load();
	 	function onSearchClick6(e) { 
			grid6.load({
				key : keyText6.value 
			});
		}
		
		function onCloseClick6(e) {
			var lookup2 = nui.get("lookup6");
			lookup2.hidePopup(); 
		}
		
		function onClearClick6() {
			var lookup2 = nui.get("lookup6");
			lookup2.deselectAll();
		}
								

								
		//查看日志列表
        function addLink(e){
			if(e.column.name == "oprate"){		
									
				var rowline = e.row.sfId;//scheduid
				var docType = e.row.sfType;
				
				var styleGray = "style='float:left; margin: 2px; background:#555555; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
				var styleBlue = "style='float:left; margin: 2px; background:#008cba; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
				var styleDisable = "style='float:left; margin: 2px; background:#a7a7a7; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
				var styleRed = "style='float:left; margin: 2px; background:#e66534; color:#fff; text-align: center; display: inline-block; border-radius:8px; padding:4px 10px; border:none;'";
				
				
				var mobanButton = "<a><button "+styleBlue+" onclick='downloadMB("+rowline+")'>下载模板</button></a>";
				var uploadButton = "<a><button "+styleGray+" onclick='uploadDoc("+e.row.sfId+")'>上传</button></a>";
				var downloadButton = "<a><button "+styleBlue+" onclick='downloadDoc(\""+encodeURI(e.row.sfAddress)+"\")'>下载</button></a>";
				var deleteButton = "<a><button "+styleRed+" onclick='delectSelfDoc("+rowline+")'>删除文档</button></a>";
				
				var disableButton = "<a><button "+styleDisable+" disabled='disabled'>完成</button></a>";
				
				if (docType == 2) { //self add doc
					e.cellHtml = deleteButton;
				} else {
					e.cellHtml = mobanButton;
				}
				
				e.cellHtml += uploadButton;
				if(e.row.sfAddress!=null){
				e.cellHtml += downloadButton;
			}
				
			}
			
			if(e.column.name == "filename") {
				var docType = e.row.sfType;
				if (docType == 2) { //self add doc
					e.cellHtml = "用户自定义文档";
				}
			}
		}
		
		//下载指定行的模板
		function downloadMB(sfid) {
			var json = "{'sfid':" + sfid+"}";
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.getTemplateDownloadAddress.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	                
	                var templateDownloadAddress = returnJson['address'];
	                	
	                	//nui.alert("templateDownloadAddress="+templateDownloadAddress);
	                	downloadDoc(templateDownloadAddress);
	                }else{
	                    nui.alert("下载模板失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                          
	                        }
	                    });
	                }
	            }
	   		 });
		}
		
		//用户上传文件按钮响应按钮
		function uploadDoc(sfid) {
			nui.open({
							url: "<%= request.getContextPath() %>/xmgl/MangerUploadfile.jsp?sfid="+sfid+"&projectId="+globalprojectId,
	                        title: "上传文件",
	                        width: 600,
	                        height: 200,
	                        ondestroy: function (action) { //弹出页面关闭前
	                        //console.log("close dialog"+action);
	                        
	                        //just refresh
	                          showUIState(globalStatus);
	                        
								if (action == "ok") { //如果点击“确定”
									console.log("close dialog");
							
								}
							}
	                        
						});
						
			
		}
		
	
		
		//删除用户自定义文档
		function delectSelfDoc(sfid) {
		
			var json = "{'sfid':" + sfid+"}";
	
	        $.ajax({
	            url:"com.zhmy.xmgl.zhmyprojectmanage.deleteSelfDefineDoc.biz.ext",
	            type:'POST',
	            data:json,
	            cache:false,
	            contentType:'text/json',
	            success:function(text){
	                var returnJson = nui.decode(text);
	                if(returnJson.exception == null){
	             
	                	grid.reload();
	                	nui.alert("删除自定义文档成功");
	                }else{
	                    nui.alert("删除自定义文档失败", "系统提示", function(action){
	                        if(action == "ok" || action == "close"){
	                          
	                        }
	                    });
	                }
	            }
	   		 });
		}
				
      function downloadDoc(attAddress) {
      	location.href= "<%= request.getContextPath()%>/xmgl/filedownLoad.jsp?attAddress="+attAddress;
      }
		
	</script>
</body>
</html>
